<?php

namespace app\admin\model\kuerp;

use think\Model;
use traits\model\SoftDelete;

class SaleGoalsDetail extends Model
{

    use SoftDelete;
    // 表名
    protected $name = 'kuerp_sale_goals_detail';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';

    protected $hidden = ['deletetime'];

    public function salegoals()
    {
        return $this->belongsTo('SaleGoals','salegoal_id','id');
    }


/**
	 * 根据字段获取月数字
	 */
	public static function getFieldMonth($field) {
		switch ($field) {
			case 'month_1':
				$date = '01';
			break;
			case 'month_2':
				$date = '02';
			break;
			case 'month_3':
				$date = '03';
			break;
			case 'month_4':
				$date = '04';
			break;
			case 'month_5':
				$date = '05';
			break;
			case 'month_6':
				$date = '06';
			break;
			case 'month_7':
				$date = '07';
			break;
			case 'month_8':
				$date = '08';
			break;
			case 'month_9':
				$date = '09';
			break;
			case 'month_10':
				$date = '10';
			break;
			case 'month_11':
				$date = '11';
			break;
			case 'month_12':
				$date = '12';
			break;
			default:
				return false;
		}

		return $date;
	}


}
